<?php
class Search extends MY_Controller{
    public function __construct() {
        parent::__construct();
		$this->load->model('model_search');
		$this->load->model('model_home');
        $this->load->model('mtype');
		$this->load->library('pager');
    }
	public function index(){
		if(!$_GET){die();}
		$desina = $this->fillter($this->input->get("destinations"));
		$holida = $this->fillter($this->input->get("holiday"));
        $duration = $this->fillter($this->input->get("duration"));
		$limit = 7;
		$start = $this->pager->start();
		$total = $this->model_search->count_search($desina,$holida,$duration);
		//echo $total;
		//die();
		$pages = $this->pager->page($total,$limit);
		$data['template'] = "search/content";
		$data['blogvie'] = $this->model_home->blog(1);
		$data['blogcam'] = $this->model_home->blog(2);
		$data['bloglao'] = $this->model_home->blog(3);
		$data['vietnam'] = $this->destination(1);
		$data['cambodia'] = $this->destination(2);
		$data['hlaos'] = $this->destination(3);
		$data['holiday'] = $this->holiday();
		$data['destination'] = $this->model_home->destination();
		$data['listpage'] = $this->pager->listpage_s($pages,$start,$limit,$desina,$holida,$duration);
		$data['listall'] = $this->model_search->search($desina,$holida,$duration,$limit,$start);
		//$this->debug($data['listall']);
		$data['title'] = "Search result - Holidays in vietnam";
		$this->load->view("search/layout",$data);
	}
}